package tests
{
	import org.flashbrighton.as3bots.bots.MattsBot;
	import org.flashbrighton.as3bots.events.HitBotEvent;
	import org.flashbrighton.as3bots.events.HitWallEvent;
	import org.flexunit.asserts.assertEquals;
	import org.flexunit.asserts.assertTrue;

	public class MattsBotControllerTest
	{
		public function MattsBotControllerTest()
		{
		}
		
		private var bot:MattsBot;		
		
		[Before]
		public function runBeforeEveryTest():void { 
			// reset controller
			bot= new MattsBot();
		}   
		
		[After]  
		public function runAfterEveryTest():void {   
			// nothing
		} 
		
		/**
		 * If the bot hit the wall right in the face(0), it must go backward wih slower speed
		 */
		[Test]  
		public function testOnHitWall():void {
			// initialisation
			bot.enginePower = 1;
			bot.steeringPower = 0;
			
			// test
			var event:HitWallEvent = new HitWallEvent(0);
			bot.onHitWall(event);
			
			// verify
			assertTrue(bot.getEnginePower()<0);
			assertTrue(bot.getEnginePower()>-1);
		}

		/**
		 * If the bot hit a Robot on the front right part, it must go on and turn right
		 */
		[Test]  
		public function testOnHitRobot_frontRight():void {
			// initialisation
			bot.enginePower = 1;
			bot.steeringPower = 0;
			
			// test
			var event:HitBotEvent = new HitBotEvent(0.2);
			bot.onHitBot(event);
			
			// verify
			assertEquals(1, bot.getEnginePower());
			assertTrue(bot.getSteeringPower()>0);
		}
		/**
		 * If the bot hit a Robot on the front left part, it must go on and turn left
		 */
		[Test]  
		public function testOnHitRobot_frontLeft():void {
			// initialisation
			bot.enginePower = 1;
			bot.steeringPower = 0;
			
			// test
			var event:HitBotEvent = new HitBotEvent(-0.2);
			bot.onHitBot(event);
			
			// verify
			assertEquals(1, bot.getEnginePower());
			assertTrue(bot.getSteeringPower()<0);
		}

	}
}